package com.yunhe.authority.controller.base;

import com.yunhe.authority.domain.base.Notification;
import com.yunhe.authority.service.base.NotificationService;
import com.yunhe.common.model.PageParam;
import com.yunhe.common.model.ResultObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhengbo
 * @date 2021/5/20 15:47
 */

@Api(value = "notification",description = "消息通知", tags = {"Authority_Notification"})
@RestController
@RequestMapping("/notification")
public class NotificationController {

    @Autowired
    private NotificationService notificationService;

    @ApiOperation("获取通知消息列表")
    @ApiImplicitParams({

    })
    @RequestMapping(value = "/searchNotificationList", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> searchNotificationList(@ModelAttribute PageParam pageParam) {
        Page<Notification> notificationPage = notificationService.searchNotificationList(pageParam);
        return new ResponseEntity<>(new ResultObject<>(notificationPage), HttpStatus.OK);
    }

    @ApiOperation("新增通知消息")
    @ApiImplicitParams({

    })
    @RequestMapping(value = "/creatNotification", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> creatNotification(@RequestBody Notification notification) {
        Notification newNotification = notificationService.creatNotification(notification);
        return new ResponseEntity<>(new ResultObject<>(newNotification), HttpStatus.OK);
    }
}
